package com.aoxin.util.enumerate;

import com.aoxin.util.ErrorUtil;

/**
 * 操作类型
 * 
 * @author Melody
 * @date 2018年3月26日 下午3:42:23
 */
public enum OperateType {
	
	INSERT(1, "添加"), DELETE(2, "删除"), UPDATE(3, "修改"), QUERY(4, "查询"),LOGOUT(5, "注销");

	private int id;

	private String value;

	private OperateType(int id, String value) {
		this.id = id;
		this.value = value;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public static OperateType fromId(int id) {
		switch (id) {
		case 1:
			return INSERT;
		case 2:
			return DELETE;
		case 3:
			return UPDATE;
		case 4:
			return QUERY;
		case 5:
			return LOGOUT;
		}
		throw new RuntimeException(String.format(ErrorUtil.OPERATE_TYPE, id));
	}
}
